package com.carrot.common.config;


import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.carrot.common.utils.SnowflakeIdUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 全局分布式ID生成器
 * 雪花算法
 */
@Component
@Slf4j
public class CustomIdGenerator implements IdentifierGenerator {

    @Override
    public Long nextId(Object entity) {
        //返回生成的id值即可.
        return SnowflakeIdUtil.nextId();
    }
}
